var websocket = require('../../utils/websocket.js');

//获取应用实例
var app = getApp();

var user = {};

Page({
    data: {
        user:{}
    },
    onShareAppMessage: function () {
        return {
        title: '微信积分小游戏',
        desc: '最具人气的小程序开发联盟!',
        path: '/page/index/index?groupid=123'
        }
  },
   formBindsubmit:function(e){
    if(e.detail.value.point.length==""||e.detail.value.detail.length==""||e.detail.value.num.length==""){
        return "";
    }else{
        var loginUser = app.getLoginUser();
        console.log("发送消息前获取usr:"+JSON.stringify(loginUser))
        var msg = {uid:loginUser.uid,pwd:loginUser.pwd,point:parseFloat(e.detail.value.point)*100,num:e.detail.value.num,detail:e.detail.value.detail};
         console.log("dianji=="+JSON.stringify(msg));
        websocket.send("point",msg);
        wx.navigateBack({
          delta: 1, // 回退前 delta(默认为1) 页面
          success: function(res){
            // success
          },
          fail: function() {
            // fail
          },
          complete: function() {
            // complete
          }
        })
    }
   },
   formReset:function(e){
    console.log("reset")
   },
  onLoad: function () {
      //调用应用实例的方法获取全局数据
      var that = this
    app.getUserInfo(function(userInfo){
     user = userInfo;
     that.setData({user:user});
    });
  }
})